import _ from "lodash";
import jsonData1 from './1.json' assert {type: 'json'};
import jsonData0 from './0.json' assert {type: 'json'};

let mockData = async () => {
    let list = []
    //最少1次 最多3次  重试
    _.range(1, _.random(2, 4)).forEach(item => {
        list.push(jsonData1)
    })
    list.push(jsonData0)
    return list
}

//模拟5个接口进来
let reqList = [mockData, mockData, mockData, mockData, mockData]

let main = async () => {
    for (let i = 0; i < reqList.length; i++) {
        let mockDataList = await reqList[i]()
        for (let j = 0; j < mockDataList.length; j++) {
            let data = await mockDataList[j]
            if (data.value === 1) {
                console.log(`当前是第${i + 1}个接口，第${j + 1}次请求，值为1 需要再次请求`)
            } else {
                console.log(`当前是第${i + 1}个接口，第${j + 1}次请求，值为0 ，请求下一个接口啦`)
                break
            }
        }
    }

    console.log(`全部完成啦~开心 (*^▽^*)`)
}

main()